#ifndef STEREORIG_H
#define STEREORIG_H

#include "includes/OpencvIncludes.h"

class StereoRig
{
private:
    cv::Mat _Extrinsic_R;
    cv::Mat _Extrinsic_T;
    cv::Mat _Extrinsic_Q;
    cv::Mat _Extrinsic_R1;
    cv::Mat _Extrinsic_R2;
    cv::Mat _Extrinsic_P1;
    cv::Mat _Extrinsic_P2;

    cv::Mat _Intrinsic_M1;
    cv::Mat _Intrinsic_M2;
    cv::Mat _Intrinsic_D1;
    cv::Mat _Intrinsic_D2;

    cv::Mat _RectifyMap_mx1;
    cv::Mat _RectifyMap_mx2;
    cv::Mat _RectifyMap_my1;
    cv::Mat _RectifyMap_my2;

    cv::Mat imgDisparity8U;
    cv::Mat imgDisparity16S;

    cv::Size _CapturedImageSize;

    cv::VideoCapture CaptureL, CaptureR;
    cv::Mat FrameCaptureL, FrameCaptureR;

public:
    StereoRig(int _CameraLeftId, int _CameraRightId, int _ImageWidth, int _ImageHeight);
    ~StereoRig();
    void LoadCameraParams();
    bool GetLeftImage(cv::Mat *_ImageLeft, cv::Mat *_ImageLeftGray);
    bool GetRightImage(cv::Mat *_ImageRight, cv::Mat *_ImageRightGray);
    void SetCaptureParams(int _CameraLeftSysId, int _CameraRightSysId, int _CaptureWidth, int _CaptureHeight);
    void LoadRectifyMapParams();
    cv::Mat RectifyImage(cv::Mat _StdImg, cv::Mat _Xmap, cv::Mat _Ymap);
    cv::Mat GetDisparityMap(cv::Mat _ImageLeft, cv::Mat _ImageRight, cv::Mat *_Reproject3d);
};

#endif // STEREORIG_H
